<?php
$this->breadcrumbs=array(
    'Widgets'=>array('/Cms/admin/widget/admin'),
    'Unused',
);

$grid = $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'widget-grid',
    'dataProvider'=>$model->unused(),
    'filter'=>$model,
    'selectableRows'=>2,
    'columns'=>array(
        array(
            'class'=>'CCheckBoxColumn',
            'value'=>'$data->id',
            'htmlOptions'=>array('width'=>'3%'),
        ),
        array(
            'name'=>'name',
            'type'=>'html',
            'value'=>'CHtml::link($data->name, array("/Cms/admin/widget/update", "id"=>$data->id), array("title"=>$data->name))',
        ),
        array(
            'name'=>'description',
            'value'=>'$data->description',
        ),
        array(
            'name'=>'type',
            'value'=>'$data->typeText',
            'filter'=>$model->typeOptions,
        ),
        array(
            'name'=>'creation_datetime',
            'value'=>'Yii::app()->getDateFormatter()->formatDateTime(strtotime($data->creation_datetime))',
            'filter'=>false,
            'htmlOptions'=>array(
                'class'=>'datetime-column'
            )
        ),
        array(
            'name'=>'last_update',
            'value'=>'Yii::app()->getDateFormatter()->formatDateTime(strtotime($data->last_update))',
            'filter'=>false,
            'htmlOptions'=>array(
                'class'=>'datetime-column'
            )
        ),
        array(
            'class'=>'CButtonColumn',
            'template'=>'{update} {delete}',
        ),
    ),
));

if ($grid->dataProvider->ItemCount) {
    $this->menu[] = array('label' => 'Delete selected items', 'url'=>$this->createUrl('delete'), 'linkOptions' => array('onclick'=>'return multipleDelete("widget-grid",this.href)'));
    Yii::app()->clientScript->registerScriptFile(Yii::app()->core->AssetUrl.'/scripts/gridview.js');
}